package com.cbgolf.oa.model;

import android.app.Activity;
import com.cbgolf.oa.base.BaseModel;
import com.cbgolf.oa.entity.OrderDetailsBean;
import com.cbgolf.oa.net.NetCallBack;
import com.cbgolf.oa.net.Web;
import com.cbgolf.oa.net.WebAPI;
import com.cbgolf.oa.presenter.IPresenterImp;
import com.cbgolf.oa.util.ErrorUtil;
import com.cbgolf.oa.util.TextUtil;
import com.cbgolf.oa.util.Util;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Created by Administrator on 2017/11/5.
 */

public class AccountDetailsModel extends BaseModel {

    private IPresenterImp worker;

    public AccountDetailsModel(Activity act, IPresenterImp worker) {
        this.worker = worker;
        super.init(act);
    }
    public void getData(String customerId,String recordDate) {
        if (!Util.isNetWorkConnected()) {
            worker.getDataFail(ErrorUtil.NONET);
            return;
        }
        String url = WebAPI.account_details_get + "/" + customerId;
        Map<String, String> map = new HashMap<>(1);
        map.put("recordDate", TextUtil.Text(recordDate));
        worker.showProgress();
        Web.getOK(url, map, new NetCallBack(response -> {
            worker.stopProgress();
            if (!isResOk(response)) {
                worker.getDataFail(errorMsg);
                return;
            }
            worker.getDataSuccess(getBean(response, OrderDetailsBean.class));
        }));
    }
}
